package pers.dawnyang.modular.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import pers.dawnyang.common.domain.entity.SysMenu;
import pers.dawnyang.modular.system.domain.request.menu.MenuReqR;
import pers.dawnyang.modular.system.domain.response.menu.MenuDtree;
import pers.dawnyang.modular.system.domain.response.menu.MenuInfo;
import pers.dawnyang.modular.system.domain.response.menu.MenuRes;
import pers.dawnyang.modular.system.mapper.SysMenuMapper;
import pers.dawnyang.modular.system.service.MenuService;

@Service
public class MenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements MenuService {

    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Override
    public List<MenuRes> getList(MenuReqR req) {
        return sysMenuMapper.getMenuList(req);
    }

    @Override
    public MenuInfo getMenuInfo(Long menuId) {
        return sysMenuMapper.getMenuInfo(menuId);
    }

    @Override
    public List<MenuDtree> getDtreeList() {
        return sysMenuMapper.getDtreeList();
    }

    @Override
    public boolean checkParentType(Long parentId) {
        SysMenu sysMenu = sysMenuMapper.selectById(parentId);
        if (2 == sysMenu.getMenuType()) {
            return false;
        }
        return true;
    }

}
